#pragma once

#include <memory>
#include <functional>

class Event;
class Subscriber;


class EventHandler final
{
public:
    EventHandler(std::weak_ptr<Subscriber> subscriber);
    ~EventHandler();

    void set_callback(std::function<void(Event&)> callback, unsigned int priority = 0);
    void operator()(Event& event)const;
    bool is_valid() const;
    void set_priority(unsigned int priority);
    bool operator<(const EventHandler& other) const;

private:
    std::weak_ptr<Subscriber> _subscriber;
    std::function<void(Event&)> _callback;
    unsigned int _priority;
};